<template>
<div>

  <h1>训练营</h1>
  {{id}}
  <p>请输入用户名：<input type="text" v-model="username"></p>
  <button @click="add">确定</button>
</div>
</template>

<script>
export default {
  name: "active",
  data(){
  return{
  id:this.$route.query.id,
  username:'',
  order_id:'',
  money:''
  }
  },
  methods:{
  add(){
      this.$axios.post('/courses/record',{'id':this.id,'username':this.username})
        .then(res=>{
          if(res.data.code==2001){
            alert('ok')
            // localStorage.setItem('money',res.data.money)
            // localStorage.setItem('order_id',res.data.order_id)
            this.order_id = res.data.order_id
            this.money = res.data.money

            this.$router.push({path:'/order',query:{'order_id':this.order_id,'money':this.money}})
            this.username = ''
          }
           else if(
           res.data.code==200
           ){
           alert('od')
           }
           else {
           alert(res.data.mes)
           }
        })

    }},


}
</script>

<style scoped>

</style>
